﻿namespace Sidvall.IdentityManager.Security
{
	public class PasswordHasher : IPasswordHasher
	{
		public string HashPassword(string password)
		{
			return SystemContext.Current.UserManager.PasswordHasher.HashPassword(password);
		}
		public PasswordVerificationResult VerifyHashedPassword(string passwordHash, string password)
		{
			var result = SystemContext.Current.UserManager.PasswordHasher.VerifyHashedPassword(passwordHash, password);
			switch (result)
			{
				case Microsoft.AspNet.Identity.PasswordVerificationResult.Success:
					return PasswordVerificationResult.Success;
				case Microsoft.AspNet.Identity.PasswordVerificationResult.SuccessRehashNeeded:
					return PasswordVerificationResult.SuccessRehashNeeded;
				default:
					return PasswordVerificationResult.Failed;
			}
		}
	}
}
